home *** CD-ROM | disk | FTP | other *** search
- include dvapi.inc
-
- comment * =================================================================
-
- Copyright (C) 1989 George A. Stanislav
- All Rights Reserved
-
- Purpose: Open a DESQview window and execute a task defined by
- a PIF file passed on the command line tail.
-
- * =========================================================================
-
- prog segment para public 'CODE'
-
- assume cs:prog, ds:prog, es:prog, ss:prog
-
- org 100h ; Make it a .COM program
-
- dvexec proc near
-
- ; Initialize the program: Make it use only 2 K memory for itself.
-
- mov ax, 2044
- mov sp, ax ; Shrink program size to bear minimum
- push ds
- pop es
- mov bx, 128 ; Release unneeded memory
- mov ah, 4ah
- int 21h
-
- ; Print Copyright notice
-
- lea dx, copr
- mov ah, 9
- int 21h
-
- ; Check if DESQview is present
-
- @call dvpresent ; Use DVAPI.INC macro
- test ax, ax
- jz $noDV ; DESQview not installed
-
- ; Parse command line
-
- mov bx, 80h
- mov cl, [bx] ; command line length
- or cl, cl ; anything there?
- jz $noCL ; nope
-
- sub ch, ch
- inc cx ; command line tail size
- $blanks:
- inc bx ; next byte
- mov al, [bx]
- cmp al, ' ' ; junk?
- ja $line
- loop $blanks
-
- ; Nothing but junk on command line, exit:
-
- jmp short $noCL
-
- $line:
- mov word ptr CL_start, bx
- $line1:
- cmp al, ' ' ; end of string?
- jbe $endline
-
- cmp al, 'a' ; lower case char?
- jb $line2
-
- cmp al, 'z'
- ja $line2
-
- sub al, 32 ; convert to upper case
- mov [bx], al
-
- $line2:
- inc bx ; next char
- mov al, [bx]
- loop $line1
-
- $endline:
- mov al, 0
- mov [bx], al ; Create an ASCIIZ string
- mov word ptr CL_end, bx
-
- ; Open file
-
- mov ax, 3d00h
- mov dx, word ptr CL_start
- int 21h
- jc $badOpen
-
- ; Read PIF file to buffer
-
- push ax ; Save handle for closing
- mov bx, ax
- mov cx, 500 ; a little extra size
- mov ah, 3fh
- lea dx, pif
- int 21h
-
- jc $badRead
-
- ; Call DESQview to run new process
-
- mov bx, ax ; number of bytes actually read
- lea di, pif
- @call newproc
- mov word ptr task, bx
-
- ; Close PIF file
-
- pop bx ; Restore file handle
- mov ah, 3eh
- int 21h
-
- call success
-
- ; Exit with errorlevel 0
-
- mov ax, 4c00h
- int 21h
-
- $noDV: lea dx, noDV ; Print error message
- err: mov ah, 9
- int 21h
-
- mov ax, 4c01h ; Exit with errorlevel 1
- int 21h
-
- $noCL: lea dx, noCL
- jmp err
- $badOpen:
- lea dx, badOpen
- err1: mov ah, 9
- int 21h
-
- mov bx, CL_end
- mov al, '$'
- mov [bx], al
- mov dx, CL_start
- jmp err
- $badRead:
- lea dx, badRead
- jmp err1
-
- ; Data:
-
- even
-
- task dw 0
- CL_start dw 0
- CL_end dw 0
- copr db 13, 'DVEXEC - version 02-Mar-1989', 13, 10
- db 'Copyright (C) George A. Stanislav', 13, 10
- db 'All rights reserved', 13, 10, 10
- db '$'
- noDV db 'DESQview not loaded.', 13, 10, '$'
- noCL db 'No PIF specified.', 13, 10, '$'
- badOpen db 'Can''t open $'
- badRead db 'Can''t read $'
- OKmsg db 'Running $'
- taskstr db 13, 10, 'with task handle $'
- done db '.', 13, 10, '$'
- dverror db 'DESQview couldn''t run $'
-
- dvexec endp
-
- taskno proc near
-
- ; Print out task number, followed by a period, cr, and lf.
-
- sub ax, ax ; End of string marker
- push ax
-
- mov ax, task
- $tloop:
- sub dx, dx
- mov bx, 10 ; decimal system
- div bx
- add dl, '0' ; convert to ASCII
- push dx
- or ax, ax ; more?
- jne $tloop
-
- ; Now pop the chars off the stack and print them
-
- $tlp:
- pop dx
- or dx, dx ; end of string?
- je $tdone
- mov ah, 2 ; print char
- int 21h
- jmp $tlp
-
- $tdone:
- lea dx, done ; Print dot, cr, lf
- mov ah, 9
- int 21h
-
- ret ; Return to caller
-
- taskno endp
-
- success proc near
-
- mov bx, task
- or bx, bx ; did we succeed?
- jne $suc
- lea dx, dverror ; no handle, failure
- mov ah, 9
- int 21h
-
- call taskname
-
- mov ax, 4c02h ; exit with errorlevel 2
- int 21h
-
- $suc: lea dx, OKmsg ; Announce success
- mov ah, 9
- int 21h
-
- call taskname
-
- lea dx, taskstr ; task string
- mov ah, 9 ; Print it out
- int 21h
-
- call taskno ; Print task number
-
- ret ; Return to caller
-
- success endp
-
- taskname proc near
-
- lea dx, pif[2] ; Get process name
- mov bx, 1 ; Standard output - redirectable
- mov cx, 30 ; Name can be up to 30 bytes long
- mov ah, 40h
- int 21h ; Print it out
-
- ret ; return to caller
-
- taskname endp
-
- pif:
-
- prog ends
- end dvexec
-
-
-